import configparser

from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError

from bean.PrivateFundManagerClassificationInfo_urls import create_table

# 创建ConfigParser对象
config = configparser.ConfigParser()

# 读取配置文件
config.read('database_config.ini')
config.read("../database_config.ini")

# 获取数据库连接配置信息
host = config.get('Database', 'host')
port = config.get('Database', 'port')
username = config.get('Database', 'username')
password = config.get('Database', 'password')
db_name = config.get('Database', 'database')

# 获取数据库实例
db = None
try:
    db = create_engine(f'mysql+pymysql://{username}:{password}@{host}:{port}/{db_name}?charset=utf8')
    # 其他操作
except SQLAlchemyError as e:
    print("数据库连接错误:", e)

if __name__ == '__main__':
    create_table(db)
